//
//  LKBaseView.m
//  Mideleague_Shop
//
//  Created by Zhiwang on 2020/5/25.
//  Copyright © 2020 Zhiwang. All rights reserved.
//

#import "LKBaseView.h"

@implementation LKBaseTableview

+(instancetype)setTableviewWithFrame:(CGRect)frame style:(UITableViewStyle)style registercellClasss:(NSArray *)classnames{
    
    LKBaseTableview *tableview = [[LKBaseTableview alloc] initWithFrame:frame style:style];
    tableview.separatorStyle = UITableViewCellSeparatorStyleNone;
    tableview.showsVerticalScrollIndicator = NO;
    tableview.showsHorizontalScrollIndicator = NO;
    if (classnames != nil) {
        for (NSString *classname in classnames) {
            UINib *nib = [UINib nibWithNibName:classname bundle:nil];
            [tableview registerNib:nib forCellReuseIdentifier:classname];
        }
    }
    return tableview;
}

@end

@implementation LKBaseLabel

+(instancetype)labelWithFrame:(CGRect)frame text:(NSString *)text textColor:(UIColor *)textColor font:(UIFont *)font textAlignment:(NSTextAlignment)textAlignment{
    LKBaseLabel *label = [[LKBaseLabel alloc] initWithFrame:frame];
    label.text = text;
    label.textColor = textColor;
    label.font = font;
    label.textAlignment = textAlignment;
    return label;
}

@end

@implementation LKBaseButton

+(instancetype)buttonWithFrame:(CGRect)frame type:(UIButtonType)type title:(NSString *)title titleColor:(UIColor *)color layercorne:(CGFloat)radio font:(UIFont *)font backgroudColor:(UIColor *)bgcolor AndActionBlock:(actionBlock)block{
    LKBaseButton *button = [LKBaseButton buttonWithType:type];
    button.frame = frame;
    [button setTitle:title forState:UIControlStateNormal];
    [button setTitleColor:color forState:UIControlStateNormal];
    button.layer.cornerRadius = radio;
    button.layer.masksToBounds = YES;
    button.backgroundColor = bgcolor;
    button.titleLabel.font = font;
    [button addTarget:button action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
    button.block = block;
    return button;

}
-(void)buttonAction:(UIButton *)btn{
    WS(weakSelf)
    if (weakSelf.block) {
        __strong typeof(self) strongSelf = weakSelf;
        strongSelf.block(btn);
    }
}


@end

@implementation   LKBaseTableCell

-(void)awakeFromNib{
    [super awakeFromNib];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}
@end


@implementation LKBaseView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
